package controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.web.bind.annotation.RequestMapping;

import vo.UserEntity;
import dao.UserLoginRegistDao;
import data.UserLoginRegistDaoImpl;

public class UserController {

	private UserLoginRegistDao ulrd = new UserLoginRegistDaoImpl();
	
	@RequestMapping("/stuLogin")
	public String login(String phoneNum,String pwd,HttpServletRequest request){
		
		
		UserEntity s=ulrd.login(phoneNum, pwd);
		if(s!=null){
			request.getSession().setAttribute("s", s);
			return "WEB-INF/jps/loginSuc";
		}
		else{
			return "login";
		}
		
		
	}
	@RequestMapping("/stuRegist")
	public String regist(UserEntity s,HttpServletRequest request){
		System.out.println(s.getUsername()+"........");
		int rs=ulrd.regist(s);
		if(rs>0)
		return "redirect:/regSuc.jsp";
		else return "regist";
	}
	
}
